/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (CVector2 - 2D Vector Class)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson	<B00137077@studentmail.uws.ac.uk>
*				John Gray			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop			<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/

#ifndef CVECTOR2
#define CVECTOR2

#include <cmath>

class CVector2
{
private:
	float x, y;

public:
	//////////////////////////////////////////////////////////
	//					Constructors						//
	//////////////////////////////////////////////////////////
	CVector2() : x(0), y(0) { }
	CVector2( float a, float b ) : x(a), y(b) { }

	//////////////////////////////////////////////////////////
	//					Accessor Methods					//
	//////////////////////////////////////////////////////////
	const float& getX () const				{ return x; }
	void  setX ( float fX )					{ x = fX; }

	const float& getY () const				{ return y; }
	void  setY ( float fY )					{ x = fY; }

	//////////////////////////////////////////////////////////
	//				Operator overloads						//
	//////////////////////////////////////////////////////////

	// comparison
	bool operator== ( CVector2& vec );

	// negation
	CVector2 operator- ();

	// assignment
	const CVector2& operator= ( const CVector2& vec );

	// addition
	const CVector2& operator+= ( const CVector2& vec );
	
	// subtraction
	const CVector2& operator-= ( const CVector2& vec );

	// scaling up
	const CVector2& operator*= ( const float& fScale );

	// scaling down
	const CVector2& operator/= ( const float& fScale );

	// addition w/o modification
	const CVector2 operator+ ( const CVector2& vec ) const;

	// subtraction w/o modification
	const CVector2 operator- ( const CVector2& vec ) const;

	// scaling up w/o modification
	const CVector2 operator* ( const float& fScale ) const;

	// scaling down w/o modification
	const CVector2 operator/ ( const float& fScale ) const;

	
	//////////////////////////////////////////////////////////
	//					Class Functions						//
	//////////////////////////////////////////////////////////
	
	// dot product
	const float dot ( const CVector2& vec ) const;

	// vector length
	const float length() const;

	// unit vector
	const CVector2 unit() const;

	// normalize - make this vector a unit vector
	void normalize ( void );

	// update this vector
	void update ( const CVector2& vec );
	void update ( float fX, float fY );
};
#endif